package jp.dodododo.dao.types;

import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

public enum SQLTypes implements SQLType {
	STRING(Types.CHAR),
	//
	NUMBER(Types.NUMERIC),
	//
	DATE(Types.DATE),
	//
	TIMESTAMP(Types.TIMESTAMP),
	//
	TIME(Types.TIME),
	//
	BINARY(Types.BINARY),
	//
	OBJECT(Types.JAVA_OBJECT),
	//
	BOOLEAN(Types.BOOLEAN),
	//
	SQLXML(Types.SQLXML),
	//
	NULL(Types.NULL);

	private int type;

	private static final Map<Integer, SQLTypes> VALUES = new HashMap<Integer, SQLTypes>();

	private SQLTypes(int type) {
		init(type);
	}

	private void init(int type) {
		this.type = type;
		if (VALUES != null) {
			VALUES.put(type, this);
		}
	}

	public int getType() {
		return type;
	}

	public static SQLTypes valueOf(int type) {
		return VALUES.get(type);
	}
}
